<template>
  <div class="card content-box">
    <p id="hello">hello2</p>
    <p id="timemsg">timemsg {{ msgText ? msgText : "Listening for timemsg event..." }}</p>
    <p id="time">{{ innerText ? innerText : "Listening for Time event..." }}</p>
    <button @click="handleToLogin">发送事件</button>
  </div>
</template>

<script setup lang="ts" name="roleManage">
import { ref } from "vue";
import { Events } from "@wailsio/runtime";

const innerText = ref("");
Events.On("time", time => {
  console.log(time);
  innerText.value = time.data;
});

const msgText = ref("");
Events.On("timemsg", msg => {
  console.log(msg);
  msgText.value = msg.data;
});
const handleToLogin = () => {
  console.log("aa");
  Events.Emit({ name: "jsTime", data: { time: new Date().toLocaleTimeString() } });
};
</script>
